Appending data to files using python